package com.example.spring5.事务;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class BankDaoImpl implements  BankDao{
    @Autowired
    JdbcTemplate jdbcTemplate;


    @Override
    public void plusMoney(String username,Double range) {
        String sql = "update bank set money=money+? where username=?";
        Object[] args = {range,username};
        int update = jdbcTemplate.update(sql, args);
        System.out.println(update);
    }

    @Override
    public void reduceMoney(String username,Double range) {
        String sql = "update bank set money=money-? where username=?";
        Object[] args = {range,username};
        int update = jdbcTemplate.update(sql, args);
        System.out.println(update);
    }

}